package org.example.myportfolio.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.example.myportfolio.config.response.JsonResult;
import org.example.myportfolio.dao.mapper.TagMapper;
import org.example.myportfolio.pojo.po.TagPO;
import org.example.myportfolio.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class TagServiceImpl implements TagService {


    @Autowired
    private TagMapper tagMapper;

    @Override
    public void createTag(String tagName) {
        log.debug("创建标签入参：{}",tagName);
        TagPO tagPO = new TagPO();
        tagPO.setName(tagName);
        try {
            int insert = tagMapper.insert(tagPO);
            if(insert == 1){
                log.info("创建标签成功");
            }else{
                log.error("创建标签失败");
                throw new RuntimeException("创建标签失败");
            }
        } catch (Exception e) {
            log.error("创建标签失败:{}",e.getMessage(),e);
            throw new RuntimeException("创建标签失败",e);
        }
    }
}
